home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Doco ƒ / CSMP ƒ / CSMP-V1-067.TXT < prev    next >
Encoding:
Text File  |  1992-06-03  |  46.9 KB  |  1,273 lines

  1. C.S.M.P. Digest             Sat, 02 May 92       Volume 1 : Issue 67
  2.  
  3. Today's Topics:
  4.  
  5.     Black Window Confuses Finder
  6.     Has any body used Turbo Pascal for Macintosh?
  7.     How do I set a page of memory to no access?
  8.     where to find Harvest C
  9.     More Map cdev questions
  10.     Multifinder Friendliness Advice
  11.     KILL! KILL! KILL! (the Finder, that is)
  12.     Determining locale of Volume
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. These digests are available (by using FTP, account anonymous, your email
  18. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  19. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  20. Questions list.  The last several issues of the digest are available from
  21. sumex-aim.stanford.edu as well.
  22.  
  23. These digests are also available via email.  Just send a note saying that you
  24. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  25. automatically receive each new digest as it is created.
  26.  
  27. The articles in these digests are taken directly from comp.sys.mac.programmer.
  28. They are not edited; all articles included in this digest are in their original
  29. posted form.  The only articles that are -not- included in these digests are
  30. those which didn't receive any replies (except those that give information
  31. rather than ask a question).  All replies to each article are concatenated
  32. onto the original article in the order in which they were received.  Article
  33. threads are not added to the digests until the last article added to the
  34. thread is at least one month old (this is to ensure that the thread is dead
  35. before adding it to the digests).
  36.  
  37. Send administrative mail to mkelly@cs.uoregon.edu.
  38.  
  39. -------------------------------------------------------
  40.  
  41. From: leue@galen.crd.ge.com (Bill Leue)
  42. Subject: Black Window Confuses Finder
  43. Date: 11 Mar 92 16:20:24 GMT
  44. Organization: General Electric Research & Development
  45.  
  46. No, that's not "Black Widow"...:-)
  47.  
  48. Here's a strange problem I've been having.  I wrote an application
  49. which hides the menu bar and blanks out the screen.  I hid the menu
  50. bar using Mr. Horton's code from the USENET Mac Programming Guide.
  51. I blanked the screen by defining a black, unornamented color window
  52. which covers the entire screen.  The application works fine.  It's
  53. not an extension, nor does it do anything funky to low-memory globals
  54. except for the single hack to hide the menu bar, which it carefully
  55. restores when exiting.
  56.  
  57. However, after this application is run, the Finder starts behaving
  58. strangely, with black rectangles appearing under places where things
  59. like Menus and Dialog boxes have been.  If you run an application,
  60. everything looks cool, but when Finder reasserts itself, the black
  61. rectangles reappear.  Somehow, my application seems to be clobbering
  62. some Finder structures or assumptions, but I can't think what they
  63. could be.  Sound familiar?
  64.  
  65. Environment is:  Mac IIci, 8 megs, System 7.0.
  66.  
  67. Thanks!
  68. - -Bill Leue
  69. leue@crd.ge.com
  70.  
  71.  
  72. +++++++++++++++++++++++++++
  73.  
  74. From: jpugh@apple.com (Jon Pugh)
  75. Date: 27 Mar 92 22:14:21 GMT
  76. Organization: Apple Co.
  77.  
  78. In article <28374@crdgw1.crd.ge.com>, leue@galen.crd.ge.com (Bill Leue) writes:
  79. > No, that's not "Black Widow"...:-)
  80. > Here's a strange problem I've been having.  I wrote an application
  81. > which hides the menu bar and blanks out the screen.  I hid the menu
  82. > bar using Mr. Horton's code from the USENET Mac Programming Guide.
  83. > I blanked the screen by defining a black, unornamented color window
  84. > which covers the entire screen.  The application works fine.  It's
  85. > not an extension, nor does it do anything funky to low-memory globals
  86. > except for the single hack to hide the menu bar, which it carefully
  87. > restores when exiting.
  88. > However, after this application is run, the Finder starts behaving
  89. > strangely, with black rectangles appearing under places where things
  90. > like Menus and Dialog boxes have been.  If you run an application,
  91. > everything looks cool, but when Finder reasserts itself, the black
  92. > rectangles reappear.  Somehow, my application seems to be clobbering
  93. > some Finder structures or assumptions, but I can't think what they
  94. > could be.  Sound familiar?
  95.  
  96. I have seen behavior of this sort when I first started programming the Mac
  97. and I would forget to set the port to my window. My quickdraw calls would
  98. change the state of the window manager port.  Perhaps you should check that.
  99.  
  100. Jon
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. From: jpugh@apple.com (Jon Pugh)
  105. Date: 27 Mar 92 22:14:21 GMT
  106. Organization: Apple Co.
  107.  
  108. In article <28374@crdgw1.crd.ge.com>, leue@galen.crd.ge.com (Bill Leue) writes:
  109. > No, that's not "Black Widow"...:-)
  110. > Here's a strange problem I've been having.  I wrote an application
  111. > which hides the menu bar and blanks out the screen.  I hid the menu
  112. > bar using Mr. Horton's code from the USENET Mac Programming Guide.
  113. > I blanked the screen by defining a black, unornamented color window
  114. > which covers the entire screen.  The application works fine.  It's
  115. > not an extension, nor does it do anything funky to low-memory globals
  116. > except for the single hack to hide the menu bar, which it carefully
  117. > restores when exiting.
  118. > However, after this application is run, the Finder starts behaving
  119. > strangely, with black rectangles appearing under places where things
  120. > like Menus and Dialog boxes have been.  If you run an application,
  121. > everything looks cool, but when Finder reasserts itself, the black
  122. > rectangles reappear.  Somehow, my application seems to be clobbering
  123. > some Finder structures or assumptions, but I can't think what they
  124. > could be.  Sound familiar?
  125.  
  126. I have seen behavior of this sort when I first started programming the Mac
  127. and I would forget to set the port to my window. My quickdraw calls would
  128. change the state of the window manager port.  Perhaps you should check that.
  129.  
  130. Jon
  131.  
  132. +++++++++++++++++++++++++++
  133.  
  134. From: mauser@intercon.com (Richard Chandler)
  135. Date: Tue, 31 Mar 92 17:56:32 GMT
  136. Organization: InterCon Systems Corporation
  137.  
  138. In article <22084@goofy.Apple.COM>, jpugh@apple.com (Jon Pugh) writes:
  139. > > However, after this application is run, the Finder starts behaving
  140. > > strangely, with black rectangles appearing under places where things
  141. > > like Menus and Dialog boxes have been.  If you run an application,
  142. > > everything looks cool, but when Finder reasserts itself, the black
  143. > > rectangles reappear.  Somehow, my application seems to be clobbering
  144. > > some Finder structures or assumptions, but I can't think what they
  145. > > could be.  Sound familiar?
  146.  
  147. Yeah, the Finder seems to store offscreen bitmaps of the areas under the menu 
  148. Bar at odd times, and copies them from the Window Manager port.
  149.  
  150. > I have seen behavior of this sort when I first started programming the Mac
  151. > and I would forget to set the port to my window. My quickdraw calls would
  152. > change the state of the window manager port.  Perhaps you should check that.
  153.  
  154. The most bizarre thing I did in my early days was accidentally doing a 
  155. SetOrigin on the Window Manager port.  Wooo!  That was fun.  Click over here, 
  156. the menu pops down over there, then you have to go over there to select the 
  157. items....
  158.  
  159. - --
  160. People are more violently opposed to fur than leather, because it's safer to
  161. harass rich women than biker gangs.
  162. "Ride a motorcycle.  Save Gas, Oil, Rubber, Steel, Aluminum, Parking Spaces,
  163.  The Environment, and Money.  Plus, you get to wear all the leather you want!"
  164.  Rich Chandler, DoD #296
  165.  
  166. ---------------------------
  167.  
  168. From: umnoor@ccu.umanitoba.ca (Nasir Ahmed Noor)
  169. Subject: Has any body used Turbo Pascal for Macintosh?
  170. Date: 18 Mar 92 04:08:31 GMT
  171. Organization: University of Manitoba, Winnipeg, Canada
  172.  
  173.  
  174.  
  175. Hi,
  176. Has any body used Turbo Pascal for macintosh? How would you rate it or
  177. compare it against Think Pascal. I guess that turbo does not have objects, os
  178. comparing just the pascal part, how do theses two compare. Is it worth 
  179. buying Turbo pscal?
  180.  
  181. Please post your reply.
  182.  
  183. Thanks
  184. Nasir Ahmed Noor
  185. umnoor@ccu.umanitoba.ca
  186.  
  187. +++++++++++++++++++++++++++
  188.  
  189. From: molla@paone.uucp (Levent Mollamustafaoglu)
  190. Date: 18 Mar 92 06:11:21 GMT
  191. Organization: Aiken Computation Lab, Harvard University
  192.  
  193. In article <1992Mar18.040831.25344@ccu.umanitoba.ca> umnoor@ccu.umanitoba.ca (Nasir Ahmed Noor) writes:
  194. >
  195. >
  196. >Hi,
  197. >Has any body used Turbo Pascal for macintosh? How would you rate it or
  198. >compare it against Think Pascal. I guess that turbo does not have objects, os
  199. >comparing just the pascal part, how do theses two compare. Is it worth 
  200. >buying Turbo pscal?
  201.  
  202. It is certainly not worth, for several reasons : First of all, Turbo 
  203. Pascal has not had any new versionsince 1.0, Borland does not support
  204. it. I am not even sure they sell it any more. Second, it was very buggy
  205. and was never upgraded. I would heartily recommend Think Pascal. It is
  206. very powerful, very cheap (if you can buy an educational version) and
  207. can also be used in conjunction with Think C, if you have some C libraries.
  208.  
  209.  
  210. ===========================================================================
  211. Dr. Levent Mollamustafaoglu       Harvard University    
  212. molla@paone.harvard.edu    molla@metatron.harvard.edu
  213. ===========================================================================
  214.  
  215. +++++++++++++++++++++++++++
  216.  
  217. From: riel@unixg.ubc.ca (William Riel)
  218. Date: 18 Mar 92 08:08:12 GMT
  219. Organization: University of British Columbia, Vancouver, B.C., Canada
  220.  
  221. I used to like Turbo Pascal (but that was about 4 years ago).
  222. I don't think that you can buy TP (for the mac) any more - as
  223. I understand Borland stopped doing Mac software a couple of years
  224. ago.
  225.  
  226. THINK Pascal is a far superior product.  Turbo Pascal is seriously
  227. out of date (not even multifinder friendly - I wouldn't dare try
  228. to use it under Sys 7).  Without question, the Pascal to buy is
  229. Symantic's THINK. IMHO THINK Pascal is one of the nicest programming
  230. environments available - for any platform.
  231.  
  232. Bill
  233. riel@unixg.ubc.ca
  234.  
  235. +++++++++++++++++++++++++++
  236.  
  237. From: ozma@kuhub.cc.ukans.edu
  238. Date: 18 Mar 92 15:14:05 CST
  239. Organization: University of Kansas Academic Computing Services
  240.  
  241. In article <1992Mar18.040831.25344@ccu.umanitoba.ca>, umnoor@ccu.umanitoba.ca (Nasir Ahmed Noor) writes:
  242. > Hi,
  243. > Has any body used Turbo Pascal for macintosh? How would you rate it or
  244. > compare it against Think Pascal. I guess that turbo does not have objects, os
  245. > comparing just the pascal part, how do theses two compare. Is it worth 
  246. > buying Turbo pscal?
  247. > Please post your reply.
  248. > Thanks
  249. > Nasir Ahmed Noor
  250. > umnoor@ccu.umanitoba.ca
  251.  
  252. I used it about three years ago.  Turbo Pascal for the Mac is DEAD, HISTORY,
  253. FORGET IT!  It is no longer supported by Borland, it does not have interfaces
  254. for Color Quickdraw or anything else from IM V onward.  In fact, I didn't think
  255. it was even possible to still buy it.  No, no OOP at all - never will have it. 
  256. THINK Pascal and MPW Pascal are the only options.
  257.  
  258. john calhoun
  259. "...chained to the pillars / a 3-day party / i break the walls
  260. and kill us all / with holy fingers..."  The Pixies
  261.  
  262.  
  263. +++++++++++++++++++++++++++
  264.  
  265. From: drc@claris.com (Dennis Cohen)
  266. Date: 20 Mar 92 13:18:57 GMT
  267. Organization: Claris Corporation, Santa Clara CA
  268.  
  269. ozma@kuhub.cc.ukans.edu writes:
  270.  
  271. >In article <1992Mar18.040831.25344@ccu.umanitoba.ca>, umnoor@ccu.umanitoba.ca (Nasir Ahmed Noor) writes:
  272. >> 
  273. >> Hi,
  274. >> Has any body used Turbo Pascal for macintosh? How would you rate it or
  275. >> compare it against Think Pascal. I guess that turbo does not have objects, os
  276. >> comparing just the pascal part, how do theses two compare. Is it worth 
  277. >> buying Turbo pscal?
  278. >> 
  279. >> Please post your reply.
  280. >> 
  281. >> Thanks
  282. >> Nasir Ahmed Noor
  283. >> umnoor@ccu.umanitoba.ca
  284.  
  285. >I used it about three years ago.  Turbo Pascal for the Mac is DEAD, HISTORY,
  286. >FORGET IT!  It is no longer supported by Borland, it does not have interfaces
  287. >for Color Quickdraw or anything else from IM V onward.  In fact, I didn't think
  288. >it was even possible to still buy it.  No, no OOP at all - never will have it. 
  289. >THINK Pascal and MPW Pascal are the only options.
  290.  
  291. Up until the last sentence, John was pretty much right on (except that I've seen
  292. places that are still selling it).  There is a 3rd option, and that is
  293. MetroWerks Pascal.  MW Pascal is published by MacMillan and lists for $79, with
  294. lower, educational pricing available.  It doesn't have OOP language extensions
  295. in the 1.0 release, but does have Turbo 5.5 source compatibility (except for
  296. register twiddling, which is platform dependent).  The manual is a pretty
  297. decent, textbook-appearing, hardbound volume and the environment does include
  298. a source-level debugger; however, the debugger is not as mature as LightsBug
  299. in THINK Pascal.  They started shipping MW Pascal just before MacWorld a
  300. couple of months ago.
  301.  
  302.  
  303. +++++++++++++++++++++++++++
  304.  
  305. From: trimper@edsi.plexus.COM (Greg Trimper)
  306. Date: 19 Mar 92 21:03:39 GMT
  307. Organization: Enterprise Data Systems Incorporated, Appleton WI
  308.  
  309. Turbo Pascal-
  310.  
  311. Worthless.  Is no longer supported as a product by Borland, doesn't
  312. work on much beyond a Mac SE or II under system 6, is clumsy, useless,
  313. and basically not worth the time or money.
  314.  
  315.  
  316. THINK is quite a nice package.  I bought Turbo a few years ago,
  317. when it was still a valid product - within a month, I had purchased
  318. THINK and dumped Turbo.  No comparison.
  319.  
  320.  
  321.                     GTr
  322.                     
  323.  
  324. +++++++++++++++++++++++++++
  325.  
  326. From: jjohnson@ewsvax.mdcbbs.com
  327. Date: 18 Mar 92 08:06:37 GMT
  328. Organization: McDnDSpaceSys, Huntington Bch, CA
  329.  
  330. In article <1992Mar18.080812.12876@unixg.ubc.ca>, riel@unixg.ubc.ca (William Riel) writes:
  331. [ stuff deleted]
  332. >  
  333. > THINK Pascal is a far superior product.  Turbo Pascal is seriously
  334. > out of date (not even multifinder friendly - I wouldn't dare try
  335. > to use it under Sys 7).  Without question, the Pascal to buy is
  336. > Symantic's THINK. IMHO THINK Pascal is one of the nicest programming
  337. > environments available - for any platform.
  338.  
  339. I heartily agree... but if you can get your hands on the "Turbo Tutor" for TP
  340. for the Mac, snap it up. It's a book/disk package with a book that's one of the
  341. best I've seen on explaining nearly all the essential parts of doing a Mac
  342. program in Pascal(without using compiler-specific features). It spends a good
  343. portion talking about pointers,handles, and casting with examples that aren't
  344. terribly dry/esoteric... (Cartwright & Reed's Pascal Primer is funnier, but it
  345. doesn't cover quite as much ground)...
  346.  
  347. Jeff Johnson
  348. jjohnson%ewsvax.decnet@mdcgwy.mdc.com
  349.  
  350. ---------------------------
  351.  
  352. From: david@oahu.cs.ucla.edu (David Dantowitz)
  353. Subject: How do I set a page of memory to no access?
  354. Date: 20 Mar 92 15:54:16 GMT
  355. Organization: UCLA Computer Science Department
  356.  
  357.  
  358. I am testing some code and would like my program to trap into the debugger
  359. when a certain address is read or written.  I'm using System 7, but could
  360. also run the test under system 6 if need be the case.
  361.  
  362. More succinctly: I have an array and I am trying to test for access to the
  363. array at the end of the array.  The actual resolution is not that
  364. important, i.e., if I get a report that some address within a PAGE was
  365. accessed, that would be sufficient.  The array has a few thousand elements,
  366. but the error I see occurs when element 65535 is accessed (index -1) and
  367. most of the time that indicates an error.
  368.  
  369. Thanks for any help.  There are otherways to catch such an error, but the
  370. nature of the code makes the above solution the simplest because I can just
  371. ask the memory manager to lock a single page of memory rather than changing
  372. many lines of code.
  373.  
  374. Thanks,
  375. - -- 
  376. David Dantowitz
  377. david@cs.ucla.edu
  378.  
  379. Singing Barbershop when I'm not doing parallel simulation
  380.  
  381. +++++++++++++++++++++++++++
  382.  
  383. From: ABSURD@applelink.apple.com (Tim Dierks, ToyMeister, Cray abuser)
  384. Date: 31 Mar 92 04:19:55 GMT
  385. Organization: MacDTS, Apple Computer
  386.  
  387. In article <1992Mar20.155416.9568@cs.ucla.edu>, david@oahu.cs.ucla.edu (David Dantowitz) writes:
  388. > I am testing some code and would like my program to trap into the debugger
  389. > when a certain address is read or written.  I'm using System 7, but could
  390. > also run the test under system 6 if need be the case.
  391. > More succinctly: I have an array and I am trying to test for access to the
  392. > array at the end of the array.  The actual resolution is not that
  393. > important, i.e., if I get a report that some address within a PAGE was
  394. > accessed, that would be sufficient.  The array has a few thousand elements,
  395. > but the error I see occurs when element 65535 is accessed (index -1) and
  396. > most of the time that indicates an error.
  397. > Thanks for any help.  There are otherways to catch such an error, but the
  398. > nature of the code makes the above solution the simplest because I can just
  399. > ask the memory manager to lock a single page of memory rather than changing
  400. > many lines of code.
  401.  
  402. To test whether it's being read, you'll have to use Jasik's Debugger.  As far
  403. as I know, it is the only program which manipulates the MMU to set up
  404. watchpoints.  This will also do a write check.
  405.  
  406. You can test whether it's being written with MacsBug (and I think with TMON,
  407. too).  In MacsBug, use the ss command.  This steps through your program,
  408. checksumming a range of memory after every instruction to find out when it
  409. changes.  Needless to say, this is _very_ slow.  For better speed, but less
  410. resolution, use atss, which only checks at every A-trap.  This can let you
  411. localize it to a smaller range of code, but may well be useless to you if
  412. you're not making Toolbox calls in the nearby code.
  413.  
  414. Tim Dierks
  415. MacDTS, but I speak for myself
  416.  
  417. ---------------------------
  418.  
  419. From: tcn40292@uxa.cso.uiuc.edu (Tony Ng)
  420. Subject: where to find Harvest C
  421. Organization: University of Illinois at Urbana
  422. Date: Sat, 21 Mar 1992 06:23:52 GMT
  423.  
  424. Can some one tell me where I can find the Harvest C compiler
  425. or any C compilers for mac in the shareware domain?
  426.  
  427. Thanx in advance!
  428.  
  429. Tony
  430.  
  431.  
  432. +++++++++++++++++++++++++++
  433.  
  434. From: Ray.Arachelian@f204.n2603.z1.ieee.org (Ray Arachelian)
  435. Date: 28 Mar 92 21:40:00 GMT
  436. Organization: FidoNet node 1:2603/204 - Not Even Odd, Forest Hills NY
  437.  
  438. On 03-21-92, TCN40292@UXA.CSO.UIUC.EDU wrote to ALL:
  439.  
  440.  T> Can some one tell me where I can find the Harvest C compiler or any C 
  441.  T> compilers for mac in the shareware domain? 
  442.  
  443. Get Sesame C $35 from:
  444.  
  445.  Sesame Software
  446.  1215 S. Maple Rd. #303
  447.  Ann Arbor, MI 48103                 
  448.  
  449.  * Freddie 1.1 * You have been found guilty of commerce with the devil.
  450.  
  451. - --  
  452. =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  453.  Ray Arachelian - Internet: Ray.Arachelian@f204.n2603.z1.ieee.org
  454.  
  455. ---------------------------
  456.  
  457. From: caston@umaxc.weeg.uiowa.edu (Catherine Caston)
  458. Subject: More Map cdev questions
  459. Date: 22 Mar 92 06:35:16 GMT
  460. Organization: Not likely!
  461.  
  462. A while back, there was a discussion of how an application can find
  463. out the location (latitude and longitude and so on) of the machine
  464. as set in the Map cdev. The only answer I saw posted required System 7.
  465. Problem is, I have developed a need to do this under System 6.0.x.
  466. I know it's possible; does anyone out there know how? Any hints, tips,
  467. pointers, revelations welcome; code fragments (C or Pascal) joyously
  468. received.
  469.  
  470. Thanks muchly in advance,
  471. Melissa Reid
  472.  
  473. +++++++++++++++++++++++++++
  474.  
  475. From: quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  476. Organization: The University of Western Australia
  477. Date: Mon, 23 Mar 1992 02:32:34 GMT
  478.  
  479. In article <11726@ns-mx.uiowa.edu>, caston@umaxc.weeg.uiowa.edu (Catherine Caston) writes:
  480. > A while back, there was a discussion of how an application can find
  481. > out the location (latitude and longitude and so on) of the machine
  482. > as set in the Map cdev. The only answer I saw posted required System 7.
  483. > Problem is, I have developed a need to do this under System 6.0.x.
  484. > I know it's possible; does anyone out there know how? Any hints, tips,
  485. > pointers, revelations welcome; code fragments (C or Pascal) joyously
  486. > received.
  487.  
  488. The MPW interface for reading the Mac's position is...
  489.  
  490. PROCEDURE ReadLocation(VAR loc: MachineLocation);
  491.     INLINE $205F,$203C,$000C,$00E4,$A051;
  492.  
  493. This translates to...
  494.  
  495.      MOVEA.L    (A7)+,A0          ; adr of loc into A0
  496.      MOVE.L     #$000C00E4,D0     ; hiwrd = 12 = sizeof(loc)
  497.                                   ; lowrd = $E4 = location in PRAM
  498.      _ReadXPRam                   ; read the PRAM
  499.  
  500. Which is simply a call to _ReadXPRam with suitable parameter mangling.  So
  501. there is no special trap.   You can call it regardless of what system
  502. your running (OK, so _ReadXPRam needs to be implemented but that certainly
  503. doesn't require System 7.).
  504.  
  505. The short answer is you can call ReadLocation on any System that implements
  506. _ReadXPRam.  If you're *truly* paranoid check for the availability of the
  507. _ReadXPRam trap.
  508.  
  509. That's not saying that you'll get valid data back though.  Half the world's
  510. Macs don't have the location set correctly anyway.
  511.  
  512. Quinn "The Eskimo!"   <quinn@cs.uwa.edu.au>  "Real Coke, Diet .sig"
  513. Department of Computer Science, The University of Western Australia
  514.   -- Mega-kudos to those responsible for the ResEdit CODE editor
  515.  
  516.  
  517. +++++++++++++++++++++++++++
  518.  
  519. From: grobbins@Apple.COM (Grobbins)
  520. Date: 24 Mar 92 04:12:54 GMT
  521. Organization: Apple DTS
  522.  
  523. In article <11726@ns-mx.uiowa.edu> caston@umaxc.weeg.uiowa.edu (Catherine Caston) writes:
  524. >A while back, there was a discussion of how an application can find
  525. >out the location (latitude and longitude and so on) of the machine
  526. >as set in the Map cdev. The only answer I saw posted required System 7.
  527. >Problem is, I have developed a need to do this under System 6.0.x.
  528.  
  529. I have posted the code below in the past.  I just tried it under 6.0.7
  530. and it worked fine.  As Quinn pointed out, checking that _ReadXPRam is
  531. implemented is about all you should have to do to ensure that this
  532. works on any Mac.
  533.  
  534. Grobbins     grobbins@apple.com
  535.  
  536. Usual disclaimers apply.
  537.  
  538. - ---
  539.  
  540.   readLocation
  541.  
  542.   retrieves the map settings for longitude and latitude and
  543.   the time offset from GMT
  544.   
  545.   for more information, see Worldwide Development: Guide to System Software
  546.   
  547.   Greg Robbins 12/91
  548.  
  549. }
  550.  
  551. { requires SIOW for WriteLn }
  552.  
  553. PROGRAM location;
  554.  
  555. USES Types, Script, FixMath;
  556.  
  557. VAR
  558.     myMachineLocation: MachineLocation;
  559.     latExt, longExt: EXTENDED;
  560.     latDeg, latMin, longDeg, longMin: LONGINT;
  561.     theGmtDelta, hours, minutes, seconds: LONGINT;
  562.     
  563.     FUNCTION GetGmtDelta(myLocation: MachineLocation): LONGINT;
  564.     VAR
  565.         internalGmtDelta: LONGINT;
  566.     BEGIN
  567.         { change 3-byte integer to LONGINT }
  568.         internalGmtDelta := BAND(myLocation.gmtDelta,$00FFFFFF);
  569.         IF BTST(internalGmtDelta,23) THEN { sign extend }
  570.             internalGmtDelta := BOR(internalGmtDelta,$FF000000);
  571.         GetGmtDelta := internalGmtDelta;
  572.     END;
  573.  
  574. BEGIN
  575.     ReadLocation(myMachineLocation);
  576.     
  577.     { convert location to extended fraction }
  578.     latExt := Frac2X(myMachineLocation.latitude);
  579.     longExt := Frac2X(myMachineLocation.longitude);
  580.     
  581.     { convert location to degrees-minutes }
  582.     latDeg := TRUNC(latExt * 90);
  583.     latMin := TRUNC((latExt * 90 - latDeg) * 60);
  584.  
  585.     longDeg := TRUNC(longExt * 90);
  586.     longMin := TRUNC((longExt * 90 - longDeg) * 60);
  587.     
  588.     { find time zone w.r.t. GMT }
  589.     theGmtDelta := GetGmtDelta(myMachineLocation);
  590.     hours := theGmtDelta DIV 3600;
  591.     minutes := (theGmtDelta MOD 3600) DIV 60;
  592.     seconds := theGmtDelta MOD 60;
  593.     
  594.     { negative values indicate South or West }
  595.     WriteLn('latitude:  ', latDeg, CHR($A1), latMin, CHR($27));
  596.     WriteLn('longitude: ', longDeg, CHR($A1), longMin, CHR($27));
  597.     
  598.     { negative values indicate West }
  599.     WriteLn('time from GMT: ', hours:3, ' h ', minutes:3, ' m ', 
  600.         seconds:2, ' s');
  601. END.
  602.  
  603. +++++++++++++++++++++++++++
  604.  
  605. From: REEKES@applelink.apple.com (Jim Reekes)
  606. Date: 26 Mar 92 23:26:59 GMT
  607. Organization: Apple Computer, Inc.
  608.  
  609. In article <11726@ns-mx.uiowa.edu>, caston@umaxc.weeg.uiowa.edu (Catherine Caston) writes:
  610. > A while back, there was a discussion of how an application can find
  611. > out the location (latitude and longitude and so on) of the machine
  612. > as set in the Map cdev. The only answer I saw posted required System 7.
  613. > Problem is, I have developed a need to do this under System 6.0.x.
  614. > I know it's possible; does anyone out there know how? Any hints, tips,
  615. > pointers, revelations welcome; code fragments (C or Pascal) joyously
  616. > received.
  617. > Thanks muchly in advance,
  618. > Melissa Reid
  619.  
  620. You can call the routine ReadLocation which returns the latitude and longitude
  621. of the machine.  These values are kept in Parameter RAM.  The problem is that
  622. if the user has not set these values for their location, then you cannot
  623. rely on them.  The Map cdev is the only way to set them, and it works under
  624. System 6.0.x.  Again, you cannot determine if the user has set their
  625. location properly so you can make use ReadLocation but cannot know if it's
  626. correct.
  627.  
  628.  
  629. - -----------------------------------------------------------------------
  630. Jim Reekes, E.O.             |     Macintosh Toolbox Engineering
  631.                              |          Sound Manager Expert
  632. Apple Computer, Inc.         | "All opinions expressed are mine, and do
  633. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  634. Cupertino, CA 95014          |       employer, Apple Computer Inc."
  635.  
  636. +++++++++++++++++++++++++++
  637.  
  638. From: dorner@pequod.cso.uiuc.edu (Steve Dorner)
  639. Organization: University of Illinois at Urbana-Champaign
  640. Date: Mon, 30 Mar 1992 21:57:15 GMT
  641.  
  642. REEKES@applelink.apple.com (Jim Reekes) writes:
  643. >System 6.0.x.  Again, you cannot determine if the user has set their
  644. >location properly so you can make use ReadLocation but cannot know if it's
  645. >correct.
  646.  
  647. While you can't tell if the user has done it correctly, you can tell if
  648. the user has done it at all.  All three values will be 0 if the user
  649. has never set the location.
  650. - -- 
  651. Steve Dorner, U of Illinois Computing Services Office
  652. Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner
  653.  
  654. ---------------------------
  655.  
  656. From: erh0362@tesla.njit.edu
  657. Subject: Multifinder Friendliness Advice
  658. Date: 22 Mar 92 20:17:24 GMT
  659. Organization: New Jersey Institute of Technology
  660.  
  661.  
  662.     Not having the Programmer's Guide to Multifinder handy (or the cash to
  663. buy it) I need a little basic advice about making my program Multifinder
  664. friendly. (If there's a particular tech note anybody could point me
  665. towards that would be great.) The first thing I need to know is what
  666. sort of sleep value I should pass to WaitNextEvent to give a reasonable
  667. amount of time to other applications running in the background.
  668.     The second question is about Suspend and Resume Events, as in what are
  669. they? What sends them? and how should I respond to them. Currently I
  670. simply stop processing if I get a Suspend event and resume processing if
  671. I get a resume event. Is there more to it than that? Here's my current
  672. suspend and resume event code for comparison:
  673.  
  674.  case app4Evt:
  675.           if ( ( gTheEvent.message & SUSPEND_RESUME_BIT) == RESUMING ) {
  676.                     go = TRUE;
  677.                     makenewboard();
  678.                 }
  679.                 else
  680.                     go = FALSE;
  681.                 break;
  682.  
  683. In particular is the "&" symbol above correct or should it be &&? I just
  684. copied this piece of the code from a book and that & looks a little
  685. suspicious.
  686.  
  687. Elliotte Rusty Harold        Department of Applied Mathematics
  688. elharo@m.njit.edu        New Jersey Institute of Technology
  689. erh0362@tesla.njit.edu        Newark, NJ 07103
  690.  
  691. +++++++++++++++++++++++++++
  692.  
  693. From: Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz)
  694. Date: 26 Mar 92 04:50:07 GMT
  695. Organization: Dartmouth College, Hanover, NH
  696.  
  697. First thing, use WaitNextEvent, but you know about sleep values so you
  698. know about WaitNextEvent. If you use TextEdit, you should pass a value
  699. less than the caret time. The fast time is 15 ticks, but if you want to
  700. be tricky, you can get the blink time (Bits 0-3 of the volClick field)
  701. and set the sleep value to the blink time-1. If you don't use textEdit
  702. (textEdit includes editText items in dialogs) you can set it anything
  703. you want, but I hear times greater than 50 ticks will crash certain
  704. machines. If you have a simple app. that doesn't do stuff in the
  705. background, set the time as high as you can, you won't be doind
  706. anything if there aren't any events anyway.
  707. Suspend and resume, they are events which you get through
  708. waitNextEvent. 
  709. Anyway, on suspend you set the cursor to something reasonable, hide any
  710. floating windows, un-hilite any selections, and convert the scrap if it
  711. needs it. On resume you first set the current grafPort to a known good
  712. one (It's supposed to be done automatically, but I hear some programs
  713. can mess that up), then call beginUpdate convert the scrap if it needs
  714. it, erase and re-dray any text and graphics, and call endUpate.
  715. More on all of this in TN's 169, 2, 126, 158, 177, 180, 185,190, 194,
  716. 202, 205, and 233.
  717.  
  718. Hope I helped,
  719. Jeremiah
  720.  
  721. +++++++++++++++++++++++++++
  722.  
  723. From: jcav@quads.uchicago.edu (JohnC)
  724. Organization: The Royal Society for Putting Things on Top of Other Things
  725. Date: Thu, 26 Mar 1992 17:18:04 GMT
  726.  
  727. Some nits to be picked:
  728.  
  729. In article <1992Mar26.045007.7669@dartvax.dartmouth.edu> JerBl@Dartmouth.edu writes:
  730. [_WaitNextEvent sleep values greater than 50 will crash certain machines]
  731. The sleep time bug exists only on machines running the original
  732. Multifinder, that is, pre-System 6.
  733.  
  734. >Suspend and resume, they are events which you get through
  735. >waitNextEvent. 
  736.  
  737. Suspend/resume (both are event 15, by the way) is an event you get if your
  738. application's SIZE resource specifies that such events are supported.
  739. Both _WaitNextEvent and _GetNextEvent will return them.
  740.  
  741. - -- 
  742. John Cavallino                  |  EMail: jcav@midway.uchicago.edu
  743. University of Chicago Hospitals |         John_Cavallino@uchfm.bsd.uchicago.edu
  744. Office of Facilities Management | USMail: 5841 S. Maryland Ave, MC 0953
  745. B0 f++ c+ g+ k s++ e+ h- pv     |         Chicago, IL  60637
  746.  
  747. +++++++++++++++++++++++++++
  748.  
  749. From: d88-jwa@hemul.nada.kth.se (Jon W{tte)
  750. Date: 26 Mar 92 20:55:38 GMT
  751. Organization: Royal Institute of Technology, Stockholm, Sweden
  752.  
  753. .dartmouth.edu> Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz) writes:
  754.  
  755.    less than the caret time. The fast time is 15 ticks, but if you want to
  756.    be tricky, you can get the blink time (Bits 0-3 of the volClick field)
  757.    and set the sleep value to the blink time-1. If you don't use textEdit
  758.  
  759. Hey, that's a roundabout and incompatible way of doing something
  760. that the trap GetCaretTime() will return for free...
  761.  
  762.    (textEdit includes editText items in dialogs) you can set it anything
  763.    you want, but I hear times greater than 50 ticks will crash certain
  764.    machines. If you have a simple app. that doesn't do stuff in the
  765.  
  766. No, that only applies to system 4.2. (i.e. multifinder 1.0)
  767. Anyone running system 6.0 and later will not be affected.
  768. DTS sample code passes 0x7fffffff to WaitNextEvent when
  769. nothing happens.
  770.  
  771.    Anyway, on suspend you set the cursor to something reasonable, hide any
  772.    floating windows, un-hilite any selections, and convert the scrap if it
  773.    needs it. On resume you first set the current grafPort to a known good
  774.  
  775. On suspend you don't touch the cursor.
  776.  
  777.    one (It's supposed to be done automatically, but I hear some programs
  778.    can mess that up), then call beginUpdate convert the scrap if it needs
  779.    it, erase and re-dray any text and graphics, and call endUpate.
  780.  
  781. I don't think you need to re-draw anything, or call beginupdate/endupdate
  782. either. What you NEED to do is handling deactivation/activation of
  783. your windows on suspend/resume; updates will take care of themselves.
  784.  
  785.    More on all of this in TN's 169, 2, 126, 158, 177, 180, 185,190, 194,
  786.    202, 205, and 233.
  787.  
  788. And Inside Mac VI, which does NOT only contain systemm 7 stuff.
  789.  
  790. - -- 
  791. h+@nada.kth.se; Jon W{tte, the Diplomat - NOT!
  792.  
  793. +++++++++++++++++++++++++++
  794.  
  795. From: lim@iris.ucdavis.edu (Lloyd Lim)
  796. Date: 28 Mar 92 02:48:26 GMT
  797. Organization: U.C. Davis - Department of Computer Science
  798.  
  799. In article <D88-JWA.92Mar26215538@hemul.nada.kth.se> d88-jwa@hemul.nada.kth.se (Jon W{tte) writes:
  800. >.dartmouth.edu> Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz) writes:
  801. >
  802. >   (textEdit includes editText items in dialogs) you can set it anything
  803. >   you want, but I hear times greater than 50 ticks will crash certain
  804. >   machines. If you have a simple app. that doesn't do stuff in the
  805. >
  806. >No, that only applies to system 4.2. (i.e. multifinder 1.0)
  807. >Anyone running system 6.0 and later will not be affected.
  808. >DTS sample code passes 0x7fffffff to WaitNextEvent when
  809. >nothing happens.
  810.  
  811. True, but there is another bug which is similar.  With System 6.0.x, if you
  812. pass a large sleep value like 0x7FFFFFFF, MultiFinder will not call
  813. SystemTask when everything is sleeping.  This is very noticeable because
  814. things like SuperClock and screensavers will never activate.  This bug
  815. is fixed in System 7.
  816.  
  817. I mentioned this bug here a while ago and some Apple people confirmed it.
  818. I guess they don't think it's really a bug because I haven't seen it
  819. documented.  Anyway, I use 50 ticks in these circumstances to make sure
  820. that screensavers will kick in.
  821.  
  822. +++
  823. Lloyd Lim     Internet: lim@cs.ucdavis.edu
  824.               America Online: LimUnltd
  825.               Compuserve: 72647,660
  826.               US Mail: 224 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
  827.  
  828. +++++++++++++++++++++++++++
  829.  
  830. From: lim@iris.ucdavis.edu (Lloyd Lim)
  831. Date: 28 Mar 92 02:48:26 GMT
  832. Organization: U.C. Davis - Department of Computer Science
  833.  
  834. In article <D88-JWA.92Mar26215538@hemul.nada.kth.se> d88-jwa@hemul.nada.kth.se (Jon W{tte) writes:
  835. >.dartmouth.edu> Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz) writes:
  836. >
  837. >   (textEdit includes editText items in dialogs) you can set it anything
  838. >   you want, but I hear times greater than 50 ticks will crash certain
  839. >   machines. If you have a simple app. that doesn't do stuff in the
  840. >
  841. >No, that only applies to system 4.2. (i.e. multifinder 1.0)
  842. >Anyone running system 6.0 and later will not be affected.
  843. >DTS sample code passes 0x7fffffff to WaitNextEvent when
  844. >nothing happens.
  845.  
  846. True, but there is another bug which is similar.  With System 6.0.x, if you
  847. pass a large sleep value like 0x7FFFFFFF, MultiFinder will not call
  848. SystemTask when everything is sleeping.  This is very noticeable because
  849. things like SuperClock and screensavers will never activate.  This bug
  850. is fixed in System 7.
  851.  
  852. I mentioned this bug here a while ago and some Apple people confirmed it.
  853. I guess they don't think it's really a bug because I haven't seen it
  854. documented.  Anyway, I use 50 ticks in these circumstances to make sure
  855. that screensavers will kick in.
  856.  
  857. +++
  858. Lloyd Lim     Internet: lim@cs.ucdavis.edu
  859.               America Online: LimUnltd
  860.               Compuserve: 72647,660
  861.               US Mail: 224 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
  862.  
  863. +++++++++++++++++++++++++++
  864.  
  865. From: Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz)
  866. Date: 31 Mar 92 03:21:25 GMT
  867. Organization: Dartmouth College, Hanover, NH
  868.  
  869. In article <D88-JWA.92Mar26215538@hemul.nada.kth.se>
  870. d88-jwa@hemul.nada.kth.se (Jon W{tte) writes:
  871.  
  872. > I don't think you need to re-draw anything, or call beginupdate/endupdate
  873. > either. What you NEED to do is handling deactivation/activation of
  874. > your windows on suspend/resume; updates will take care of themselves.
  875.  
  876. I don't claim to be an expert or anything, so I'll quote Apple. This is
  877. the System 7.0 version of "Sample", included with MPW Object Pascal.
  878.  
  879. PROCEDURE DoUpdate(window: WindowPtr);
  880.  
  881. {This is called when an update event is received for a window.
  882.  It calls DrawWindow to draw the contents of an application window.
  883.  As an effeciency measure that does not have to be followed, it
  884.  calls the drawing routine only if the visRgn is non-empty. This
  885.  will handle situations where calculations for drawing or drawing
  886.  itself is very time-consuming.}
  887.  
  888. BEGIN
  889.     IF IsAppWindow(window) THEN BEGIN
  890.         BeginUpdate(window);                    {sets up the visRgn, clears updateRgn}
  891.         IF NOT EmptyRgn(window^.visRgn) THEN    {draw if updating needs to be
  892. done}
  893.             DrawWindow(window);
  894.         EndUpdate(window);                        {restores the visRgn}
  895.     END;
  896. END; {DoUpdate}
  897.  
  898. If Apple does it, then I'll think twice about not doing it.
  899.  
  900. Jeremiah
  901. JerBl@Dartmouth.edu
  902. The opinions expressed are mine only, and not those of Apple Computer,
  903. Dartmouth College, Johnny Carson, Dan Quale, Pat Robertson (at least, I
  904. hope not), or anyone you will ever know exists. MPW is probably a
  905. trademark of someone of other.
  906.  
  907. +++++++++++++++++++++++++++
  908.  
  909. From: dougm@bradbury.cns.caltech.edu (Doug McNought)
  910. Organization: California Institute of Technology
  911. Date: Tue, 31 Mar 1992 13:39:24 GMT
  912.  
  913. In article <1992Mar31.032125.4444@dartvax.dartmouth.edu> Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz) writes:
  914. >In article <D88-JWA.92Mar26215538@hemul.nada.kth.se>
  915. >d88-jwa@hemul.nada.kth.se (Jon W{tte) writes:
  916. >
  917. >> I don't think you need to re-draw anything, or call beginupdate/endupdate
  918. >> either. What you NEED to do is handling deactivation/activation of
  919. >> your windows on suspend/resume; updates will take care of themselves.
  920. >
  921. >I don't claim to be an expert or anything, so I'll quote Apple. This is
  922. >the System 7.0 version of "Sample", included with MPW Object Pascal.
  923. >
  924. >PROCEDURE DoUpdate(window: WindowPtr);
  925.  
  926.   [Apple sample code for update handling deleted]
  927.  
  928. >If Apple does it, then I'll think twice about not doing it.
  929. >
  930. >Jeremiah
  931. >JerBl@Dartmouth.edu
  932.  
  933.   Yes, but the original question was "what do I do in response to a *resume*
  934. event?" You don't need to handle updating in that case; the Window Manager 
  935. will generate an update event in the normal manner if one is necessary (which
  936. it very well might not be).
  937. regards,
  938. doug
  939. - -- 
  940. <><><><><><><><><><><><><><><>Go Orioles<><><><><><><><><><><><><><><><>
  941. <> Doug McNaught                          dougm@descartes.caltech.edu <>
  942. <>  Help!!! I'm addicted to *Spaceward Ho!* Is there a support group? <>
  943. <><><><><><><><><><><><><><><>Go Orioles<><><><><><><><><><><><><><><><>
  944.  
  945. +++++++++++++++++++++++++++
  946.  
  947. From: d88-jwa@byse.nada.kth.se (Jon W{tte)
  948. Date: 31 Mar 92 15:30:16 GMT
  949. Organization: Royal Institute of Technology, Stockholm, Sweden
  950.  
  951. .dartmouth.edu> Jeremiah.Blatz@dartmouth.edu (Jeremiah Blatz) writes:
  952.  
  953.    d88-jwa@hemul.nada.kth.se (Jon W{tte) writes:
  954.  
  955.    > I don't think you need to re-draw anything, or call beginupdate/endupdate
  956.    > either. What you NEED to do is handling deactivation/activation of
  957.    > your windows on suspend/resume; updates will take care of themselves.
  958.                      ^^^^^^^^^^^^^^
  959.  
  960.    I don't claim to be an expert or anything, so I'll quote Apple. This is
  961.    the System 7.0 version of "Sample", included with MPW Object Pascal.
  962.  
  963.    PROCEDURE DoUpdate(window: WindowPtr);
  964.  
  965.    {This is called when an update event is received for a window.
  966.     It calls DrawWindow to draw the contents of an application window.
  967.     As an effeciency measure that does not have to be followed, it
  968.     calls the drawing routine only if the visRgn is non-empty. This
  969.     will handle situations where calculations for drawing or drawing
  970.     itself is very time-consuming.}
  971.  
  972.    If Apple does it, then I'll think twice about not doing it.
  973.  
  974.  
  975. Well, DoUpdate is of course very nice for updating the window, but
  976. you dont have to update windows on suspend/resume, since if they need
  977. updating, you'll get an update event anyway. The only reason you might
  978. want to do this is performance, since updates are prioritized pretty
  979. low, it might take a millisecond or two before you get the update
  980. event, especially if the user starts typing right away.
  981.  
  982. However, you need to activate/deactivate your (frontmost) windows on
  983. suspend/resume; this might require you to repaint the window anyway
  984. because of selections that change between outlines/inverted.
  985.  
  986. CHeers,
  987.  
  988. - -- 
  989. h+@nada.kth.se; Jon W{tte, the Diplomat - NOT!
  990.  
  991. ---------------------------
  992.  
  993. From: robichau@lambda.msfc.nasa.gov (Paul Robichaux)
  994. Subject: KILL! KILL! KILL! (the Finder, that is)
  995. Organization: New Technology, Inc.
  996. Date: Mon, 23 Mar 1992 14:52:55 GMT
  997.  
  998. I'm writing an application which needs to run without the finder. For
  999. testing, I'd like to stick in an AESend that kills the finder. 
  1000.  
  1001. The widely famous "Bride of FinderEvents" stack doesn't mention a
  1002. special quit event. Does Finder 7.0 support the core 'quit'? Is there
  1003. some other special event?
  1004.  
  1005. I'll summarize replies, since I'm sure others have had this question
  1006. (or will.)
  1007.  
  1008. - -Paul
  1009. - -- 
  1010. Paul Robichaux, KD4JZG          | NTI doesn't pay for my opinions, and NASA
  1011. robichau@lambda.msfc.nasa.gov   | doesn't know I have any.
  1012.          This message printed on recycled phosphors.
  1013.  
  1014.  
  1015. +++++++++++++++++++++++++++
  1016.  
  1017. From: rhessjr@darkside.com (Robert Hess)
  1018. Date: 29 Mar 92 18:34:49 GMT
  1019. Organization: Independent Consultant
  1020.  
  1021. In article <1992Mar23.145255.683@lambda.msfc.nasa.gov>, robichau@lambda.msfc.nasa.gov (Paul Robichaux) writes:
  1022. > Does Finder 7.0 support the core 'quit'?
  1023.  
  1024. yes.
  1025.  
  1026. ---------------------------
  1027.  
  1028. From: Joe.Francis@dartmouth.edu (Joe Francis)
  1029. Subject: Determining locale of Volume
  1030. Date: 24 Mar 92 07:48:24 GMT
  1031. Organization: Dartmouth College, Hanover, NH
  1032.  
  1033. I want to use the Desktop Manager to find an application.  However, I
  1034. am only interested in matching applications that are on the target
  1035. machine, rather than fileshared volumes from other machines or remote
  1036. appleshare volumes.  How can I determine what volumes fit my needs? I
  1037. looked at the param block filled by PBHGetVolParms() and couldn't find
  1038. a combination of attributes that looked to fit the bill.  Any clues?
  1039.  
  1040. +++++++++++++++++++++++++++
  1041.  
  1042. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  1043. Organization: NCRPDA, Curtin University
  1044. Date: Wed, 25 Mar 1992 04:27:37 GMT
  1045.  
  1046. In article <1992Mar24.074824.14606@dartvax.dartmouth.edu>, Joe.Francis@dartmouth.edu (Joe Francis) writes:
  1047. > I want to use the Desktop Manager to find an application.  However, I
  1048. > am only interested in matching applications that are on the target
  1049. > machine, rather than fileshared volumes from other machines or remote
  1050. > appleshare volumes.  How can I determine what volumes fit my needs? I
  1051. > looked at the param block filled by PBHGetVolParms() and couldn't find
  1052. > a combination of attributes that looked to fit the bill.  Any clues?
  1053.  
  1054. One way that should work is to check that the volume's server address is
  1055. zero:
  1056.  
  1057. [This code probably won't compile, but it is taken from some code that 
  1058. definitely uses the address field so I know it works in principle]
  1059.  
  1060. var
  1061.   pb: HParamBlockRec;
  1062.   volparams: packed record
  1063.     version: integer;
  1064.     attrib: longInt;
  1065.     localhand: handle;
  1066.     address: AddrBlock;
  1067.   end;
  1068.   volname:str255;
  1069.  
  1070. begin
  1071.   with pb do begin
  1072.     ioNamePtr := @volname;
  1073.     ioVRefNum := 0;
  1074.     ioVolIndex := i;
  1075.     oe := PBHGetVInfoSync(@pb);
  1076.     if oe = noErr then begin
  1077.       ioNamePtr := nil;
  1078.       ioBuffer := @volparams;
  1079.       ioReqCount := SizeOf(volparams);
  1080.       oe := PBHGetVolParmsSync(@pb);
  1081.     end;
  1082.     if oe = noErr then begin
  1083.       if longInt(volparams.address) = 0 then begin
  1084.         IsLocal;
  1085.       end else begin
  1086.         IsRemote
  1087.       end;
  1088.     end;
  1089.   end;
  1090. end.
  1091.  
  1092. HTH,
  1093.    Peter.
  1094.  
  1095. ______________________________________________________________________
  1096. Peter N Lewis, NCRPDA, Curtin University      peter@cujo.curtin.edu.au
  1097. GPO Box U1987, Perth WA 6001, AUSTRALIA            FAX: +61 9 367 8141
  1098.  
  1099.  
  1100.  
  1101. +++++++++++++++++++++++++++
  1102.  
  1103. From: grobbins@Apple.COM (Grobbins)
  1104. Date: 25 Mar 92 21:43:15 GMT
  1105. Organization: Apple DTS
  1106.  
  1107. In article <1992Mar24.074824.14606@dartvax.dartmouth.edu> Joe.Francis@dartmouth.edu writes:
  1108. >I am only interested in matching applications that are on the target
  1109. >machine, rather than fileshared volumes from other machines or remote
  1110. >appleshare volumes.  How can I determine what volumes fit my needs? I
  1111. >looked at the param block filled by PBHGetVolParms() and couldn't find
  1112. >a combination of attributes that looked to fit the bill.  Any clues?
  1113.  
  1114. Pasted below are an appropriate entry from the Q&A Stack (available on
  1115. the Developer CD and, I hope, at ftp.apple.com) and a useful routine
  1116. for locating the preferred application given its documents file spec.
  1117.  
  1118. Grobbins           grobbins@apple.com
  1119.  
  1120. Usual disclaimers apply.
  1121.  
  1122. - ---
  1123.  
  1124. from the Q&A Stack:
  1125.  
  1126. If I don't want to search any AppleShare or File Sharing volumes, how can I
  1127. tell which mounted volume to search?
  1128.  
  1129. You should be able to use the field vMServerAdr in the GetVolParmsInfo
  1130. attributes buffer of PBHGetVolParms to determine whether to search a volume.
  1131. Since the vMServerAdr field specifies the internet address of the server
  1132. that manages an AppleTalk server volume, checking for a zero internet
  1133. address before searching the volume would seem the way to go for you.
  1134.  
  1135. - ---
  1136.  
  1137.  
  1138.  
  1139.   FUNCTION FindAppFromDoc(docFSSpec: FSSpec; VAR appFSSpec: FSSpec): OSErr;
  1140.   { first find an app on the same volume; next try local volumes; 
  1141.     next try remote volumes.  System 7 only. }
  1142.     
  1143.   LABEL 1;
  1144.   TYPE
  1145.     volumePass = (document, local, remote, done);
  1146.  
  1147.   VAR
  1148.     myDTPBRec: DTPBRec;
  1149.     docFInfo, dummyFInfo: FInfo;
  1150.     retCode: OSErr;
  1151.     theVolumePass: volumePass;
  1152.     theVolumeCounter: INTEGER;
  1153.     
  1154.     myHParamBlockRec: HParamBlockRec;
  1155.     myGetVolParmsInfoBuffer: GetVolParmsInfoBuffer;
  1156.     remoteFlag, foundFlag: BOOLEAN;
  1157.  
  1158.   BEGIN
  1159.   
  1160.     theVolumePass := document;
  1161.     foundFlag := FALSE;
  1162.     
  1163.     retCode := FSpGetFInfo(docFSSpec, docFInfo);
  1164.     IF retCode <> noErr THEN GOTO 1;
  1165.  
  1166.     REPEAT  { for each kind of pass }
  1167.     
  1168.       theVolumeCounter := 0;
  1169.       
  1170.       REPEAT  { for each volume, except on first pass }
  1171.       
  1172.         { first, find the vRefNum of the volume to be checked }
  1173.         
  1174.         IF theVolumePass = document THEN { use doc's own volume }
  1175.           myDTPBRec.ioVRefNum := docFSSpec.vRefNum
  1176.         ELSE
  1177.           BEGIN
  1178.             theVolumeCounter := theVolumeCounter + 1;
  1179.             
  1180.             { loop through all drives }
  1181.             myHParamBlockRec.ioCompletion := NIL;
  1182.             myHParamBlockRec.ioNamePtr := NIL;
  1183.             myHParamBlockRec.ioVRefNum := 0;
  1184.             myHParamBlockRec.ioVolIndex := theVolumeCounter;
  1185.             retCode := PBHGetVInfoSync(@myHParamBlockRec);
  1186.             
  1187.             IF retCode = nsvErr THEN Leave; { checked all drives }
  1188.             IF retCode <> noErr THEN GOTO 1;
  1189.             
  1190.             { is this one remote? }
  1191.             myHParamBlockRec.ioBuffer := @myGetVolParmsInfoBuffer;
  1192.             myHParamBlockRec.ioReqCount := 
  1193.               Sizeof(myGetVolParmsInfoBuffer);
  1194.             retCode := PBHGetVolParmsSync(@myHParamBlockRec);
  1195.             IF (retCode <> noErr) THEN GOTO 1;
  1196.             
  1197.             { volume should be remote only on remote pass, else skip it }
  1198.             IF (myGetVolParmsInfoBuffer.vMServerAdr <> 0)
  1199.               <> (theVolumePass = remote) THEN Cycle;
  1200.             
  1201.             { found a volume of interest }
  1202.             myDTPBRec.ioVRefNum := myHParamBlockRec.ioVRefNum;
  1203.             
  1204.           END; { ELSE }
  1205.           
  1206.         myDTPBRec.ioNamePtr := NIL;
  1207.         
  1208.         { Get the application name and directory from the desktop database, if
  1209.           the volume has one. }
  1210.          
  1211.         retCode := PBDTGetPath(@myDTPBRec);
  1212.         IF (retCode = noErr) AND (myDTPBRec.ioResult = noErr) AND
  1213.           (myDTPBRec.ioDTRefNum <> 0) THEN
  1214.           BEGIN
  1215.             { get application name and directory }
  1216.             myDTPBRec.ioNamePtr := @appFSSpec.name; { change the file spec name }
  1217.             myDTPBRec.ioIndex := 0;
  1218.             myDTPBRec.ioFileCreator := docFInfo.fdCreator;
  1219.             myDTPBRec.ioCompletion := NIL;
  1220.         
  1221.             retCode := PBDTGetAPPLSync(@myDTPBRec);
  1222.             IF retCode = noErr THEN 
  1223.               BEGIN
  1224.                 appFSSpec.parID := myDTPBRec.ioAPPLParID;
  1225.                 appFSSpec.vRefNum := myDTPBRec.ioVRefNum;
  1226.                 foundFlag := TRUE;
  1227.               END;
  1228.           END;
  1229.         
  1230.       UNTIL foundFlag OR (theVolumePass = document);
  1231.         { OR ran out of drives, due to Leave statement }
  1232.       
  1233.       theVolumePass := SUCC(theVolumePass)
  1234.       
  1235.     UNTIL foundFlag OR (theVolumePass = done);
  1236.     
  1237.     IF NOT foundFlag THEN retCode := fnfErr;
  1238.   1:
  1239.     FindAppFromDoc := retCode;
  1240.   END;
  1241.  
  1242.  
  1243. +++++++++++++++++++++++++++
  1244.  
  1245. From: Joe.Francis@dartmouth.edu (Joe Francis)
  1246. Date: 31 Mar 92 21:57:08 GMT
  1247. Organization: Dartmouth College, Hanover, NH
  1248.  
  1249. Thanks for the replies, everyone.  Using the vMServerAdr field of the
  1250. GetVolParmsInfo buffer works like a charm.
  1251.  
  1252. ---------------------------
  1253.  
  1254. End of C.S.M.P. Digest
  1255. **********************
  1256.